<!DOCTYPE HTML PUBLIC "-//ORA//DTD CD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>[Chapter 30] 30.3 java.util.Date (JDK 1.0)</TITLE>
<META NAME="author" CONTENT="David Flanagan">
<META NAME="date" CONTENT="Thu Jul 31 16:34:48 1997">
<META NAME="form" CONTENT="html">
<META NAME="metadata" CONTENT="dublincore.0.1">
<META NAME="objecttype" CONTENT="book part">
<META NAME="otheragent" CONTENT="gmat dbtohtml">
<META NAME="publisher" CONTENT="O'Reilly &amp; Associates, Inc.">
<META NAME="source" CONTENT="SGML">
<META NAME="subject" CONTENT="Java">
<META NAME="title" CONTENT="Java in a Nutshell">
<META HTTP-EQUIV="Content-Script-Type" CONTENT="text/javascript">
</HEAD>
<body vlink="#551a8b" alink="#ff0000" text="#000000" bgcolor="#FFFFFF" link="#0000ee">

<DIV CLASS=htmlnav>
<H1><a href='index.htm'><IMG SRC="gifs/smbanner.gif"
     ALT="Java in a Nutshell" border=0></a></H1>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch30_02.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><B><FONT FACE="ARIEL,HELVETICA,HELV,SANSERIF" SIZE="-1">Chapter 30<br>The java.util Package</FONT></B></TD>
<td width=172 align=right valign=top><A HREF="ch30_04.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
</table>

&nbsp;
<hr align=left width=515>
</DIV>
<DIV CLASS=sect1>
<h2 CLASS=sect1><A CLASS="TITLE" NAME="JNUT2-CH-30-SECT-3">30.3 java.util.Date (JDK 1.0)</A></h2>

<DIV CLASS=sect2>
<h3 CLASS=sect2><A CLASS="TITLE" NAME="JNUT2-CH-30-SECT-3.1"></A></h3>
</DIV>

<P CLASS=para>
This class represents dates and times. It lets you work
with them in a system-independent way. You can create a
<tt CLASS=literal>Date</tt> by specifying the number of milliseconds from
the epoch (midnight GMT, January 1st, 1970), or by
specifying the year, month, date, and optionally, the hour,
minute, and second. Years are specified as the number of
years since 1900. If you call the <tt CLASS=literal>Date</tt> constructor
with no arguments, the <tt CLASS=literal>Date</tt> is initialized to
the current time and date. The instance methods of the
class allow you to get and set the various date and time
fields, to compare dates and times, and to convert dates to
and from string representations.

<P CLASS=para>
In Java 1.1, many of the date methods have been deprecated
in favor of the methods of the <tt CLASS=literal>Calendar</tt> class.

<DIV CLASS=screen>
<P>
<PRE>
public class <tt CLASS=literal>Date</tt> extends Object implements Serializable, Cloneable {
    // <tt CLASS=literal>Public Constructors</tt>
            public <tt CLASS=literal>Date</tt>();
            public <tt CLASS=literal>Date</tt>(long <tt CLASS=literal>date</tt>);
        #   public <tt CLASS=literal>Date</tt>(int <tt CLASS=literal>year</tt>, int <tt CLASS=literal>month</tt>, int <tt CLASS=literal>date</tt>);
        #   public <tt CLASS=literal>Date</tt>(int <tt CLASS=literal>year</tt>, int <tt CLASS=literal>month</tt>, int <tt CLASS=literal>date</tt>, int <tt CLASS=literal>hrs</tt>, int <tt CLASS=literal>min</tt>);
        #   public <tt CLASS=literal>Date</tt>(int <tt CLASS=literal>year</tt>, int <tt CLASS=literal>month</tt>, int <tt CLASS=literal>date</tt>, int <tt CLASS=literal>hrs</tt>, int <tt CLASS=literal>min</tt>, int <tt CLASS=literal>sec</tt>);
        #   public <tt CLASS=literal>Date</tt>(String <tt CLASS=literal>s</tt>);
    // <tt CLASS=literal>Class Methods</tt>
        #   public static long <tt CLASS=literal>UTC</tt>(int <tt CLASS=literal>year</tt>, int <tt CLASS=literal>month</tt>, int <tt CLASS=literal>date</tt>, int <tt CLASS=literal>hrs</tt>, int <tt CLASS=literal>min</tt>, int <tt CLASS=literal>sec</tt>);
        #   public static long <tt CLASS=literal>parse</tt>(String <tt CLASS=literal>s</tt>);
    // <tt CLASS=literal>Public Instance Methods</tt>
            public boolean <tt CLASS=literal>after</tt>(Date <tt CLASS=literal>when</tt>);
            public boolean <tt CLASS=literal>before</tt>(Date <tt CLASS=literal>when</tt>);
            public boolean <tt CLASS=literal>equals</tt>(Object <tt CLASS=literal>obj</tt>);  //<tt CLASS=literal> Overrides Object</tt>
        #   public int <tt CLASS=literal>getDate</tt>();
        #   public int <tt CLASS=literal>getDay</tt>();
        #   public int <tt CLASS=literal>getHours</tt>();
        #   public int <tt CLASS=literal>getMinutes</tt>();
        #   public int <tt CLASS=literal>getMonth</tt>();
        #   public int <tt CLASS=literal>getSeconds</tt>();
            public long <tt CLASS=literal>getTime</tt>();
        #   public int <tt CLASS=literal>getTimezoneOffset</tt>();
        #   public int <tt CLASS=literal>getYear</tt>();
            public int <tt CLASS=literal>hashCode</tt>();  //<tt CLASS=literal> Overrides Object</tt>
        #   public void <tt CLASS=literal>setDate</tt>(int <tt CLASS=literal>date</tt>);
        #   public void <tt CLASS=literal>setHours</tt>(int <tt CLASS=literal>hours</tt>);
        #   public void <tt CLASS=literal>setMinutes</tt>(int <tt CLASS=literal>minutes</tt>);
        #   public void <tt CLASS=literal>setMonth</tt>(int <tt CLASS=literal>month</tt>);
        #   public void <tt CLASS=literal>setSeconds</tt>(int <tt CLASS=literal>seconds</tt>);
            public void <tt CLASS=literal>setTime</tt>(long <tt CLASS=literal>time</tt>);
        #   public void <tt CLASS=literal>setYear</tt>(int <tt CLASS=literal>year</tt>);
        #   public String <tt CLASS=literal>toGMTString</tt>();
        #   public String <tt CLASS=literal>toLocaleString</tt>();
            public String <tt CLASS=literal>toString</tt>();  //<tt CLASS=literal> Overrides Object</tt>
}
</PRE>
</DIV>

</DIV>

<DIV CLASS=sect2>
<h3 CLASS=sect2><A CLASS="TITLE" NAME="JNUT2-CH-30-SECT-3.2">Passed To:</A></h3>

<P CLASS=para>
Calendar.setTime(), 
Date.after(), 
Date.before(), 
DateFormat.format(), 
GregorianCalendar.setGregorianChange(), 
SimpleDateFormat.format(), 
SimpleTimeZone.inDaylightTime(), 
TimeZone.inDaylightTime()

</DIV>

<DIV CLASS=sect2>
<h3 CLASS=sect2><A CLASS="TITLE" NAME="JNUT2-CH-30-SECT-3.3">Returned By:</A></h3>

<P CLASS=para>
Calendar.getTime(), 
DateFormat.parse(), 
GregorianCalendar.getGregorianChange(), 
SimpleDateFormat.parse()

</DIV>

</DIV>


<DIV CLASS=htmlnav>

<P>
<HR align=left width=515>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch30_02.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><a href="index.htm"><img src='gifs/txthome.gif' border=0 alt='Home'></a></td>
<td width=172 align=right valign=top><A HREF="ch30_04.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
<tr>
<td width=172 align=left valign=top>java.util.Calendar (JDK 1.1)</td>
<td width=171 align=center valign=top><a href="index/idx_0.htm"><img src='gifs/index.gif' alt='Book Index' border=0></a></td>
<td width=172 align=right valign=top>java.util.Dictionary (JDK 1.0)</td>
</tr>
</table>
<hr align=left width=515>

<IMG SRC="gifs/smnavbar.gif" USEMAP="#map" BORDER=0> 
<MAP NAME="map"> 
<AREA SHAPE=RECT COORDS="0,0,108,15" HREF="../javanut/index.htm"
alt="Java in a Nutshell"> 
<AREA SHAPE=RECT COORDS="109,0,200,15" HREF="../langref/index.htm" 
alt="Java Language Reference"> 
<AREA SHAPE=RECT COORDS="203,0,290,15" HREF="../awt/index.htm" 
alt="Java AWT"> 
<AREA SHAPE=RECT COORDS="291,0,419,15" HREF="../fclass/index.htm" 
alt="Java Fundamental Classes"> 
<AREA SHAPE=RECT COORDS="421,0,514,15" HREF="../exp/index.htm" 
alt="Exploring Java"> 
</MAP>
</DIV>

</BODY>
</HTML>
